import psycopg2
def insert_initial_data():
    try:
        connection = psycopg2.connect(
        user="postgres",
        password="ffxshlsy666",
        host="localhost",
        port="5432",
        database="transaction_lab"
        )
        
        cursor = connection.cursor()
        
        # Insert sample data for testing the accounts
        insert_accounts = """
        INSERT INTO accounts (name, balance) VALUES
        ('Alice', 1000.00),
        ('Bob', 500.00),
        ('Charlie', 1500.00)
        RETURNING account_id, name, balance;
        """
        cursor.execute(insert_accounts)
        accounts = cursor.fetchall()
 
 # Validate changes
        connection.commit()
        print("Données initiales insérées avec succès:")
        for account in accounts:
            print(f"ID: {account[0]}, Nom: {account[1]}, Solde: {account[2]}")
        
    except (Exception, psycopg2.Error) as error:
        print("Erreur lors de l'insertion des données:", error)
    finally:
        if connection:
            cursor.close()
            connection.close()
if __name__ == "__main__":
    insert_initial_data()